<?php

class Damages_FrontendController extends Zend_Controller_Action {

  const LOGIN_URL = '/';
  const LOGGED_URL = '/menu';

  public function init() {
    $this->_helper->viewRenderer->setNoRender(true);
    $compress = (bool) Zend_Registry::get('appConfig')->resources->layout->params->compress;
    $packages = new ViewPackages_PackageCreator('css', 'js/compressed', 'damages');
    if ($compress) {
      $packages->init();
      $this->view->cssFiles = $packages->getCssFiles();
      $this->view->jsFiles = $packages->getJsFiles();
    } else {
      $this->view->cssFiles = $packages->getOriginalCssFiles();
      $this->view->jsFiles = $packages->getOriginalJsFiles();
    }
    $ie9= false;
    if (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $_SERVER['HTTP_USER_AGENT'])) {
     $ie9 = true;
    }
    if (!Damages_Auth::getInstance()->isAuth() && self::LOGIN_URL != $this->getRequest()->getRequestUri()) {
      $this->_redirect(self::LOGIN_URL);
    } else if (Damages_Auth::getInstance()->isAuth() && self::LOGIN_URL == $this->getRequest()->getRequestUri() && !$ie9) {
      $this->_redirect(self::LOGGED_URL);
    }
  }

  public function indexAction() {
    
  }

}